CMake modernization: add Backward::Interface and Backward::Object targets #310
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR should make it easier to use the
backward.cpp
file in downstream projects. As documented in the README, with this PR there are now three targets:Backward::Interface
is an interface target that brings compiler definitionflags, include directory, and external libraries. This is all you need to use
the
backward.hpp
header library.Backward::Object
bringsBackward::Interface
andbackward.cpp
as anOBJECT
CMake library. This target cannot be exported, so it is notavailable when Backward is used via
find_package
.Backward::Backward
bringsBackward::Interface
andbackward.cpp
aseither
STATIC
orSHARED
library (depending on theBACKWARD_SHARED
option). This target is exported and always available, however note that the
linker will not include unused objects from a static library, unless the
-Wl,--whole-archive
option (or similar) is used.This PR marks the
add_backward
target as deprecated and removes the${BACKWARD_ENABLE}
variable.Before this PR, using the
Backward::Backward
target was not easy and consistent:BackwardConfig.cmake
defined the target such that its interface had only the things needed to usebackward.hpp
(i.e.BACKWARD_INCLUDE_DIRS
,BACKWARD_DEFINITIONS
,BACKWARD_LIBRARIES
)CMakeLists.txt
file defined the target such that it contained evenbackward.cpp
as either STATIC or SHARED librarylibbackward.a
does not have the desired effect, unless the-Wl,--whole-archive
option (or similar) is used (the linker discards unused objects from a static library)